home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 9
/
FM Towns Free Software Collection 9.iso
/
t_os
/
tool
/
wings
/
w2_src
/
font_sub.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-16
|
5KB
|
178 lines
#include <egb.h>
#include "module.h"
#include "font_sub.h"
// 10進数表示関数
void font_10( char *strptn, int page, int position, int n, int r, int zero )
{
char para[16];
int i, range = 1;
if( !r || r>=11 )
return;
if( r!=1 ){
for( i=1;i<=r-1;i++ )
range *= 10;
}
if( r==1 )
para[ 0 ] = n + 0x30;
else{
for( i=0;i<=r-2;i++ ){
para[ i ] = n / range + 0x30;
n %= range;
range /= 10;
}
para[ r-1 ] = n + 0x30;
}
if( zero ){
i = 0;
while( i!=r && para[ i ]==0x30 ){
para[ i ] = 0x20;
i++;
}
if( para[ r - 1 ]==0x20 )
para[ r - 1 ] = 0x30;
}
para[ r ] = '\0';
font_ank( strptn, page, position, para, 0 );
}
// 16進数表示関数
void font_16( char *strptn, int page, int position, int n, int r, int zero )
{
char para[16];
int i, range = 1;
if( !r || r>=9 )
return;
if( r!=1 ){
for( i=1;i<=r-1;i++ )
range *= 16;
}
if( r==1 )
para[ 0 ] = n + ( n<=9 ? 0x30 : 0x37 );
else{
for( i=0;i<=r-2;i++ ){
para[ i ] = n / range + ( (n/range)<=9 ? 0x30 : 0x37 );
n %= range;
range /= 16;
}
para[ r-1 ] = n + ( n<=9 ? 0x30 : 0x37 );
}
if( zero ){
i = 0;
while( i!=r && para[ i ]==0x30 ){
para[ i ] = 0x20;
i++;
}
if( para[ r - 1 ]==0x20 )
para[ r - 1 ] = 0x30;
}
para[ r ] = '\0';
font_ank( strptn, page, position, para, 0 );
}
// ANK 2バイト文字混合表示関数
void font_mix( char *strptn, int page, int position, char *str, int len )
{
char iskanji_1[ ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 };
int i = 0, j, jpn = 0, ank = 0, x;
if( !len )
len = 32767;
x = position;
while( len && *( str + i ) ){
if( iskanji_1[ BYTE( str + i ) ]
&& iskanji_2[ BYTE( str + i+1 ) ]
&& *( str + i+1 ) ){
while( iskanji_1[ BYTE( str + i ) ]
&& iskanji_2[ BYTE( str + i+1 ) ]
&& *( str + i+1 ) ){
i += 2;
jpn++;
}
if( len<jpn*2 ){
jpn = len / 2;
len = 0;
}
else
len -= ( jpn * 2 );
font_kan( strptn, page, x, str, jpn );
x += ( jpn * 6 );
str += i;
i = jpn = 0;
if( iskanji_1[ BYTE( str + i ) ]
&& !iskanji_2[ BYTE( str + i+1 ) ]
&& *( str + i+1 ) ){
if( len ){
if( len==1 ){
j = 1;
len = 0;
}
else {
j = 2;
len -= 2;
}
font_ank( strptn, page, x, str, j );
}
x += 6;
str += 2;
ank = 0;
}
}
else{
while( !iskanji_1[ BYTE( str + i ) ] && *( str + i ) ){
i++;
ank++;
}
if( len ){
if( len<ank ){
ank = len;
len = 0;
}
else
len -= ank;
}
font_ank( strptn, page, x, str, ank );
x += ( ank * 3 );
str += i;
i = ank = 0;
}
}
}